<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yuan1994 <tianpian0805@gmail.com>
 * @link http://tpadmin.yuan1994.com/
 * @copyright 2016 yuan1994 all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */

//------------------------
// 角色模型
//-------------------------

namespace app\common\model;

use think\Model;

class AdminRole extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';


    public function getUserRoleList($arg=null){
        $child_plaform = getChildAdminRegByPlaformId($this->plaform);
        $arrs=$this->alias('a')->join('admin_role_user b','a.id = b.role_id')->field('a.id,a.name,b.user_id')->where(['a.admin_reg'=>['in',$child_plaform],'a.isdelete'=>0,'a.status'=>1])->select();
        return $arrs;
    }

    /**
     * @param $uid
     */
    public function getRoleByUid($uid){
        $arr=$this->alias('a')->join('admin_role_user b','a.id = b.role_id')->where('b.user_id='.$uid)->select();
        return $arr;
    }
}